{extend name="Public:base" /}
      {block name="seo"}
     
      {/block}
{block name="body"}
<div class="container" id="content-container"> 
          <div class="es-panel es-panel-default">
<div class="es-panel-heading ">
<label></label>
申请创建小组<span class="es-pull-right">

</span></div>
<div class="es-panel-body ">
<form class="form-horizontal" id="groupadd">
  
  <div class="form-group">
                        <label for="inputPassword3" class="col-sm-1 control-label">所属分类</label>
                        <div class="col-sm-4">
                              <select name="pid" class="form-control">
                                                {volist name="groupcate_list" id='vo'}
                                                    <option value="{$vo.id}"  >{$vo.name}</option>
                                                {/volist}
                             </select>
                        </div>
                    </div>
                    <div class="form-group">

                        <label for="inputPassword3" class="col-sm-1 control-label">小组名称</label>
                      <div class="col-sm-4">
                            <input type="text" name="name" value="" required  lay-verify="required" placeholder="请输入小组名称" class="form-control">
                        </div>
                    </div>
   <div class="form-group">
                        <label for="inputPassword3" class="col-sm-1 control-label">小组简介</label>
                        <div class="col-sm-8">
                         <textarea name="describe" placeholder="请输入小组简介" class=""></textarea>
                        {:hook('ArticleEditor', array('name'=> 'describe','value'=> '','items'=>''))}
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="inputPassword3" class="col-sm-1 control-label">小组图片</label>
                        <div class="col-sm-8">
                         
                          <div id='upload_show_div1' style="width:120px;display: inline;">
                    <img style='max-width:100px; margin-right: 20px;' src="{:get_picture_url(0)}" />
                </div>
               
                <input type="hidden" name="cover_id" id='cover_id' value="0"/>
                         <div id="coverimg1"></div>   
                   <span class="btn btn-primary btn-sm clearid" data-name="cover_id" data-divname="upload_show_div1" >清除小组图片</span>
                        
                       
                        </div>
                    </div>
                    
                    
                                          <div class="form-group">
                        <label for="inputPassword3" class="col-sm-1 control-label">小组背景图片</label>
                        <div class="col-sm-8">
                         <div id='upload_show_div2' style="width:120px;display: inline;">
                    <img style='max-width:100px; margin-right: 20px;' src="{:get_picture_url(0)}" />
                </div>
               
                <input type="hidden" name="bg_id" id='bg_id' value="0"/>
                         <div id="coverimg"></div>
               <span class="btn btn-primary btn-sm clearid" data-name="bg_id" data-divname="upload_show_div2" >清除小组背景图</span>
                        </div>
                    </div>
                    
                    <link rel="stylesheet" href="__PUBLIC__/js/webuploader/webuploader.css" />
<script src="__PUBLIC__/js/webuploader/webuploader.nolog.min.js"></script>
<script>
$(function(){
	$('.clearid').click(function(){
		
		var id=$(this).data('name');
		var div=$(this).data('divname');
		$('#'+id).val(0);
		$('#'+div).find('img').attr('src','__PUBLIC__/images/onimg.png');
		
		
	});
	
});
var upload_param1 = WebUploader.create({

    // 选完文件后，是否自动上传。
    auto: true,

    // swf文件路径
    swf: "WEB_URL"+'/addon/imginput/static/dist/Uploader.swf',
    chunked: false,
    chunkSize: 512 * 1024,
    // 文件接收服务端。
    server: "{:url('File/pictureUpload')}",

    // 选择文件的按钮。可选。
    // 内部根据当前运行是创建，可能是input元素，也可能是flash.
    pick: {
            id: '#coverimg',
            label: '点击选择文件'
        },
        fileNumLimit: 1,
        disableGlobalDnd: true,
    // 只允许选择图片文件。
    accept: {
       
    }
});

upload_param1.on('uploadSuccess',function( file, response) {

	 var show_img_url = response.headpath;
	 upload_param1.reset();
	  
	    $( '#upload_show_div2').html("<img style='max-width:100px; margin-right: 20px;' src='"+show_img_url+"' />");
	    $('#bg_id').val(response.id);

});

var upload_param2 = WebUploader.create({

    // 选完文件后，是否自动上传。
    auto: true,

    // swf文件路径
    swf: "WEB_URL"+'/addon/imginput/static/dist/Uploader.swf',
    chunked: false,
    chunkSize: 512 * 1024,
    // 文件接收服务端。
    server: "{:url('File/pictureUpload')}",

    // 选择文件的按钮。可选。
    // 内部根据当前运行是创建，可能是input元素，也可能是flash.
    pick: {
            id: '#coverimg1',
            label: '点击选择文件'
        },
        fileNumLimit: 1,
        disableGlobalDnd: true,
    // 只允许选择图片文件。
    accept: {
    
    }
});

upload_param2.on('uploadSuccess',function( file, response) {

	 var show_img_url = response.headpath;

	 upload_param2.reset();
	    $( '#upload_show_div1').html("<img style='max-width:100px; margin-right: 20px;' src='"+show_img_url+"' />");
	    $('#cover_id').val(response.id);

});

</script>
    
  <div class="form-group" style="margin-top:30px;">
    <div class="col-sm-offset-1 col-sm-5">
      <button type="button" data-url="{:url('group/groupadd')}" class="btn btn-success groupadd ajax-post"><i class="iconfont icon-yijianfankui"></i> 创建小组</button>
    </div>
  </div>
</form>

</div>
</div>

      </div>
 {/block}		
{block name="script"}
<script>
$(function(){
	$('.groupadd').click(function(){
		
	    $.post($(this).data('url'),$('form#groupadd').serialize(),function(data){
	    	
		      if(data.code == 1){
		       
		        layer.msg(data.msg, {icon: 1, time: 1000}, function(){
		          location.href="{:url('user/mygroup')}";
		        });
		      }else{
		       
		        layer.msg(data.msg, {icon: 2, anim: 6, time: 1000});
		        
		       
		        
		      }
		    });
		    return false;
		
		
	});
	
	
});
</script>


{/block}